<?php

class system{

    function __construct(){
        return true;
    }

    static function exception($name, $data){
        $name = trim(preg_replace('/[^a-zA-Z0-9-_\.]/', '', $name));
        $filename = "_Exception_" . $name . "-_." . ".exc.logs";
        $data = json_encode([
            date("Y-m-d H:i:s"),
            $_SERVER['REMOTE_ADDR'],
            "DATA" => [
                $name => $data
            ],
            "_SERVER" => $_SERVER,
            "_REQUEST" => $_REQUEST,
            "memory" => [
                "usage" => memory_get_usage(),
                "peak_usage" => memory_get_peak_usage(),
                "peak_usage_real" => memory_get_peak_usage(true)
            ]
        ]);

        file_put_contents(xSystemConfig::logDir . $filename, $data . PHP_EOL, FILE_APPEND);
    }

}

?>
